package com.dk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.dk.mapper.DicFunctionMapper;
import com.dk.pojo.DicFunction;
import com.dk.pojo.DicRecord;
import com.dk.service.DicFunctionService;
import com.dk.vo.DicFunctionVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class DicFunctionServiceImpl implements DicFunctionService {

    @Resource
    private DicFunctionMapper functionMapper;

    @Override
    public List<DicFunctionVO> getCarDicFunction(Long cid) {
        LambdaQueryWrapper<DicFunction> wrapper = Wrappers.<DicFunction>lambdaQuery().eq(!StringUtils.isEmpty(cid.toString()),
                DicFunction::getId, cid);
        List<DicFunction> functionList = functionMapper.selectList(wrapper);

        List<DicFunctionVO> voList = new ArrayList<>();
        functionList.forEach(i -> {
            DicFunctionVO vo = new DicFunctionVO();
            BeanUtils.copyProperties(i, vo);
            voList.add(vo);
        });
        return voList;
    }
}
